package com.kdtech.analyse.news;
import com.kdtech.analyse.AnalyseNews;
import com.kdtech.utils.HtmlCleaner;

import com.kdtech.analyse.common.AnalyseSelector;
import com.kdtech.analyse.common.NewsAnalyseConfig;
import com.kdtech.crawler.CrawlHTML;
import com.kdtech.crawler.at.UrlArgumentTop;
import com.kdtech.entity.crawler.UrlMeta;
import com.kdtech.entity.data.NewsMeta;

/**
 *第一女人  网站解析
 * @author Chase	
 *
 */
public class Miss_no1NewsAnalyse implements AnalyseNews {
	
	private static final String[] regex={
		"http://.*.miss-no1.com/.*/[0-9]*/[0-9]*/[0-9]*/.*.htm"
	};
		
	
			
	public boolean isDetailPage(String url) {
		for (int i=0; i < regex.length; i++) {
			if (url.matches(regex[i])) {
				return true;
			}
		}
		return false;
	}

	
	public NewsMeta parserHtml(UrlMeta urlMeta) {		
		
		NewsAnalyseConfig config=new NewsAnalyseConfig("第一女人");
		//标题解析规则
		config.getTitleRegexs().add(AnalyseSelector.init().select("title").substringBefore("_"));		
		//正文解析规则
		config.getContentRegexs().add(AnalyseSelector.init().select("div#content,div#Zoom"));		
		//日期解析规则
		config.getDateRegexs().add(AnalyseSelector.init().select(("div.date,div.riqi")));
		return  null;//AbstractCommNewsAnalyse.parseHtmlWithConfig(urlMeta, config);	
	}
	
	public static void main(String[] args) {	
		Miss_no1NewsAnalyse analyse=new Miss_no1NewsAnalyse();
		String url="http://fashion.miss-no1.com/file/2014/02/11/531321@110005_1.htm";
		System.out.println(analyse.isDetailPage(url));
		url=UrlArgumentTop.FromatUrl(url);
		UrlMeta meta=CrawlHTML.responseToURL(url);
		System.out.println(analyse.parserHtml(meta));
	}

	
	public NewsMeta Update(NewsMeta meta) {
		return null;
	}
	

	
	public boolean isNeedUpdate(){
		return false;
	}
}
